<?php

namespace App\Models;

use Exception;
use Illuminate\Database\Eloquent\Factories\HasFactory;


/*总数字资源model*/

class ResourceTotalType extends BaseModel
{
    use HasFactory;

    const CREATED_AT = 'create_time';
    const UPDATED_AT = 'change_time';

    
    protected $table = 'resource_total_type';



    /**
     * 列表
     * @param limit int 分页大小
     * @param keywords string 搜索关键词
     */
    public function lists($keywords = null, $limit = 10)
    {
        $res = $this->select(['id', 'type_name', 'create_time'])
            ->where(function ($query) use ($keywords) {
                if ($keywords) {
                    $query->where('type_name', 'like', "%$keywords%");
                }
            })
            ->where('is_del', 1)
            ->orderByDesc('id')
            ->paginate($limit)
            ->toArray();
        return $res;
    }
}
